use crate::models::ai::config;
use crate::{impl_model_convert, impl_schema_convert};
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CreateConfig {
    pub base_url: String,
    pub api_key: Option<String>,
    pub temperature: Option<Decimal>,
    pub top_p: Option<Decimal>,
    pub model: String,
    pub kind: String,
    pub current_use: Option<i32>,
    pub name: String,
}
impl_model_convert!(CreateConfig => config::ActiveModel{kind, base_url, api_key, temperature, top_p, model,current_use, name});

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ListItem {
    pub id: String,
    pub base_url: String,
    pub api_key: Option<String>,
    pub temperature: Option<Decimal>,
    pub top_p: Option<Decimal>,
    pub model: String,
    pub kind: String,
    pub current_use: Option<i32>,
    pub name: String,
}
impl_schema_convert!(config::Model => ListItem {kind, id, base_url, api_key, temperature, top_p, model,current_use, name });

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UpdateConfig {
    pub id: String,
    pub base_url: String,
    pub api_key: Option<String>,
    pub temperature: Option<Decimal>,
    pub top_p: Option<Decimal>,
    pub model: String,
    pub kind: String,
    pub current_use: Option<i32>,
    pub name: String,
}
impl_schema_convert!(config::Model => UpdateConfig {kind, id, base_url, api_key, temperature, top_p, model,current_use, name });
impl_model_convert!(UpdateConfig => config::ActiveModel{kind, id, base_url, api_key, temperature, top_p, model,current_use, name });

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct OperateConfig {
    pub id: String,
}
